/**
 *
 */
package edu.hawaii.duedates.configuration;

import static org.junit.Assert.assertEquals;
import java.io.File;
import java.util.List;
import org.junit.Test;
import edu.hawaii.duedates.configuration.jaxb.Library;
import edu.hawaii.duedates.configuration.jaxb.User;
import edu.hawaii.duedates.configuration.jaxb.Users;


/**
 * JUnit test class for ConfigurationManager to see if its reading in the
 * duedates.xml file properly.
 *
 * @author Phillip Ka Hung Lau
 * @author John Ly
 * @author Scheller Sanchez
 * @author Robin Raqueno
 */
public class TestConfigurationManager {
 
  /**
   * Read in duedates.xml and see that it was processed correctly.
   * @throws Exception If problem occurs.
   */
  @Test
  public void testConfigurationManager() throws Exception {
    File exampleDuedatesXml = new File(System.getProperty("user.dir") + "/xml/duedates.xml");
    ConfigurationManager manager = new ConfigurationManager(exampleDuedatesXml);
    edu.hawaii.duedates.configuration.jaxb.DueDates duedates = manager.getDueDates();
    Users users = duedates.getUsers();
    List<User> listUsers = users.getUser();

    assertEquals("Get User1 name", "Philip Johnson", listUsers.get(0).getName());
    assertEquals("Get User1 email", "johnson@hawaii.edu", listUsers.get(0).getEmail());
    assertEquals("Get User1 password", "password", listUsers.get(0).getPassword());
    assertEquals("Get User2 name", "Shaoxuan", listUsers.get(1).getName());
   
    List<Library> libraries = listUsers.get(0).getLibrary();
    assertEquals("Get User1 library1 name", "University of Hawaii", libraries.get(0).getName());
    assertEquals("Get User1 library1 username", "johnson", libraries.get(0).getUsername());
    assertEquals("Get User1 library1 password", "password", libraries.get(0).getPassword());
    assertEquals("Get User1 library2 name", "Hawaii State Library", libraries.get(1).getName());    
  }
 
}

